/***************************************************************************
 *   Copyright (C) 2008 by Jesse Crossen   *
 *   jesse.crossen@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef STROBE_H
#define STROBE_H

#include "math.h"

#include <QWidget>
#include <QPainter>
#include <QPainterPath>

// the number of segments in the strobe display
#define SEGMENTS (24)

/**
	@author Jesse Crossen <jesse.crossen@gmail.com>
*/
class Strobe : public QWidget
{
Q_OBJECT
public:
    Strobe(QWidget *parent = 0);

    ~Strobe();
    
    const QSize sizeHint();
    
    // the brightness values for each segment in the display
    float Segments[SEGMENTS];

protected:
  void paintEvent(QPaintEvent *event);
  
  // the frequency being tuned to
  float noteFrequency;
  // the name of the note we're tuning to
  QString noteName;
  // the current position of the revolving "wheel" (between 0.0 and 1.0)
  float spinPhase;
  // the threshold to use between dark and light on the display as a fraction of peak value
  float contrast;
  
public slots:
  void setNoteFrequency(float frequency);
  void setNoteName(QString name);
  void setContrast(float newContrast);
  void addAudio(const float *buffer, unsigned long framesPerBuffer,
                float sampleRate, float peak);

};

#endif
